package day07;

public class Transformer {
    /*
     使用武器接口
     武器接口变成变形金刚的成员
     */
    private Weapon weapon;
    public void setWeapon(Weapon weapon){
        this.weapon = weapon;
    }
    public void attack(){
        if(weapon == null){
            System.out.println("用牙咬");
            return;
        }
        String str = "";
        switch (weapon.getType()){
            case Weapon.TYPE_COLD: str = "冷兵器"; break;
            case Weapon.TYPE_HOT: str = "热兵器"; break;
            case Weapon.TYPE_NUCLEAR: str = "核武器"; break;
        }

        // 使用核武器狼牙棒进攻
        System.out.println("使用"+str+weapon.getName()+"进攻");
        weapon.Kill();
    }
}
